<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Lysee Reference Manual - Create module</title>
<link href="index.css" rel="stylesheet" type="text/css">
<link href="logo.ico" rel="Shortcut Icon">
</head>
<body> 
<table width="760" border="0" align="center" cellpadding="0" cellspacing="8"> 
  <tr> 
    <td align="left" valign="middle"> <table width="100%"  border="0" cellspacing="0" cellpadding="0"> 
        <tr> 
          <td align="left" valign="top"><a href="index.html"><img src="logo.png" width="490" height="70" border="0"></a></td> 
        <td align="right" valign="bottom"><a href="400.html">&lt;PREV</a>&nbsp;&nbsp;<a href="index.html">HOME</a>&nbsp;&nbsp;<a href="402.html">NEXT&gt;</a></td>
        </tr> 
      </table></td> 
  </tr> 
  <tr> 
    <td class="footer_line">
      <strong><strong>4.1 <a href="index.html">Lysee Reference Manual</a> - </strong><a href="300.html"></a></strong><a href="400.html">Developments</a> - <strong>Create module</strong><br> 
          <br> 
    This page explains how to write LYSEE module with project lysee_zipper.</td> 
  </tr> 
  <tr> 
    <td><strong>4.1.1 Load zipper </strong><br> 
      <br> 
      <table width="600"  border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td nowrap class="dosprompt">&gt;&gt;&gt; import zipper;<br>
            &gt;&gt;&gt; = zipper.file;<br>
            C:\lysee\modules\zipper.dll<br>
          &gt;&gt;&gt;</td>
        </tr>
      </table><br>
      There are the steps LYSEE load zipper module:<br>      
      <ol>
        <li>Search and find zipper.dll in ${search} path.</li>
        <li>Load zipper.dll into LYSEE space.</li>
        <li> Setup zipper module.</li>
        <li> Get address of InitExchange function from zipper.dll.</li>
        <li> Call InitExchange with zipper module and function  QueryEntry.<br>
        At this time, zipper.dll registers its informations into zipper module.</li>
        <li>Setup classes, functions in zipper module with zipper's informations.</li>
    </ol>
      Important:<br>
    <ol>
      <li>LYSEE module must export function InitExchange.</li>
      <li>Module must register its information (classes, function and others) in  InitExchange function.</li>
    </ol></td> 
  </tr>
  <tr>
    <td><strong><a name="prepare"></a>4.1.2 Prepare functions</strong><br>
      <br>
      zipper exports 4 module functions:<br>
      <blockquote>
      <table  border="0" cellpadding="4" cellspacing="0">
        <tr>
          <th class="bottom_line">Name</th>
          <th class="bottom_line">Description</th>
        </tr>
        <tr>
          <td align="center" bgcolor="#FFDFFF" class="bottom_line">list</td>
          <td align="left" class="bottom_left_line"> List sub file names in a zip file</td>
        </tr>
        <tr>
          <td align="center" bgcolor="#FFDFFF" class="bottom_line">unzip</td>
          <td align="left" class="bottom_left_line">unzip all files</td>
        <tr>
          <td align="center" bgcolor="#FFDFFF" class="bottom_line">unzipf</td>
          <td align="left" class="bottom_left_line">unzip one file </td>
        <tr>
          <td align="center" bgcolor="#FFDFFF" class="bottom_line"> zip </td>
          <td align="left" class="bottom_left_line">create zip file </td>
      </table></blockquote>
      (1) Realize these functions: <br> 
      <blockquote><strong>procedure</strong> zipper_list(invoker: TLseInvoke);<strong>cdecl</strong>;<br>
        <strong>procedure</strong> zipper_unzip(invoker: TLseInvoke);<strong>cdecl</strong>;<br>
        <strong>procedure</strong> zipper_unzip_file(invoker: TLseInvoke);<strong>cdecl</strong>;<br>
        <strong>procedure</strong> zipper_zip(invoker: TLseInvoke);<strong>cdecl</strong>;<strong>        </strong>
</blockquote>
      (2) Register these functions in array: <br>
      <blockquote><strong>const</strong><br>
        &nbsp;&nbsp;zipper_func_count = 4;<br>
        &nbsp;&nbsp;zipper_func_array: array[0..zipper_func_count - 1] <strong>of</strong> RLseFuncRec = (<br>
        &nbsp;&nbsp;&nbsp;&nbsp;(fr_prot:'strlist list(string zipFile)';<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fr_addr:<span class="lsp_code">@zipper_list</span>;<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fr_desc:'list sub-files in source zip file'<br>
        &nbsp;&nbsp;&nbsp;&nbsp;),<br>
        &nbsp;&nbsp;&nbsp;&nbsp;(fr_prot:'void unzip(string zipFile, string outputPath)';<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fr_addr:<span class="lsp_code">@zipper_unzip</span>;<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fr_desc:'unzip all files to specified path'<br>
        &nbsp;&nbsp;&nbsp;&nbsp;),<br>
        &nbsp;&nbsp;&nbsp;&nbsp;(fr_prot:'void unzipf(string zipFile, string subFile, string outputPath)';<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fr_addr:<span class="lsp_code">@zipper_unzip_file</span>;<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fr_desc:'unzip specified sub file'<br>
        &nbsp;&nbsp;&nbsp;&nbsp;),<br>
        &nbsp;&nbsp;&nbsp;&nbsp;(fr_prot:'int zip(string zipFile, string sourceFile)';<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fr_addr:<span class="lsp_code">@zipper_zip</span>;<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fr_desc:'create zip file with passed source file or LB delimited list'<br>
        &nbsp;&nbsp;&nbsp;&nbsp;)<br>
    &nbsp;&nbsp;);</blockquote>    </td>
  </tr> 
  <tr>
    <td>
      <strong>4.1.3 Realize InitExchange function</strong><br>
          <br>
    The following is zipper's InitExchange function.<br><blockquote>
    <strong>procedure</strong> InitExchange(<strong>const</strong> MR: PLseModuleRec; <strong>const</strong> QE: TLseQueryEntry);<strong>cdecl</strong>;<br>
    <strong>begin</strong><br>
    &nbsp;&nbsp;<span class="lsp_code">lse_prepare(QE);</span><br>
    &nbsp;&nbsp;MR^.iw_production := 'fpc zip/unzip module for lysee';<br>
    &nbsp;&nbsp;MR^.iw_version := LSE_VERSION;<br>
    &nbsp;&nbsp;MR^.iw_copyright := LSE_COPYRIGHT;<br>
    &nbsp;&nbsp;MR^.iw_desc := MR^.iw_production;<br>
    &nbsp;&nbsp;MR^.iw_homepage := LSE_HOMEPAGE;<br>
    &nbsp;&nbsp;MR^.iw_email := LSE_EMAIL;<br>
    &nbsp;&nbsp;<span class="lsp_code">MR^.iw_libfuncs.count := zipper_func_count;</span><br>
    &nbsp;&nbsp;<span class="lsp_code">MR^.iw_libfuncs.entry :=@zipper_func_array;</span><br>
    &nbsp;&nbsp;<span class="lsp_code">MR^.iw_invoke :=@lse_call_gate;</span><br>
    <strong>end</strong>;<br><br>
    <span class="lsp_code"><strong>exports</strong>&nbsp;InitExchange; </span> </blockquote>Explains:<br>
    <ol>
      <li><span class="lsp_code">lse_prepare(QE);</span><br>
      get and save call-into-kernel function entries.<br>
      </li>
        <li><span class="lsp_code">MR^.iw_libfuncs.count := zipper_func_count;</span><br>set module function count.<br></li>
        <li><span class="lsp_code">MR^.iw_libfuncs.entry :=@zipper_func_array;</span><br>set module function array address.<br></li>
        <li><span class="lsp_code">MR^.iw_invoke :=@lse_call_gate;</span><br>tell kernel, the  module functions are TLseFuncInvoke type.<br></li>
        <li><span class="lsp_code"><strong>exports</strong>&nbsp;InitExchange;</span><br>
          exports InitExchange function.</li>
    </ol></td>
  </tr>
  <tr> 
    <td align="right" class="footer_line"><a href="400.html">&lt;PREV</a>&nbsp;&nbsp;<a href="index.html">HOME</a>&nbsp;&nbsp;<a href="402.html">NEXT&gt;</a></td> 
  </tr> 
</table> 
</body>
</html>
